package com.itlong.cloud.miniprogram.resource;

import com.itlong.cloud.POJO.PO.AppUserInfoPO;
import com.itlong.cloud.POJO.PO.FeedbackInfoPO;
import com.itlong.cloud.POJO.PO.WelinkBindRelationPO;
import com.itlong.cloud.POJO.VO.miniprogram.WelinkUserVO;
import com.itlong.cloud.miniprogram.service.IWelinkUserService;
import com.itlong.cloud.user.miniprogram.IWelinkServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

/**
 * <desc>
 *      welink业务暴露接口实现类
 * </desc>
 *
 * @createDate 2020/03/19
 */
@RestController
public class WelinkServiceResource implements IWelinkServiceClient{
    @Autowired
    IWelinkUserService iWelinkUserService;

    /**
     * <desc>
     *      用户登录
     * </desc>
     *
     * @param code
     * @return
     * @author Jiaqi.X
     * @createDate 2020/03/19
     */
    @RequestMapping(path = "/welink/user/login",method = RequestMethod.POST)
    @Override
    public WelinkUserVO login(@RequestParam("code") String code) throws IOException {
        return iWelinkUserService.login(code);
    }

    /**
     * <desc>
     *      检测手机号是否已绑定welink
     * </desc>
     *
     * @param phoneNum
     * @return
     * @author Jiaqi.X
     * @createDate 2020/03/19
     */
    @RequestMapping(path = "/welink/user/checkBindPhone",method = RequestMethod.POST)
    public String checkBindPhone(@RequestParam("phoneNum") String phoneNum){
        return iWelinkUserService.checkBindPhone(phoneNum);
    }

    /**
     * <desc>
     *      保存绑定关系
     * </desc>
     *
     * @param welinkBindRelationPO
     * @return
     * @author Jiaqi.X
     * @createDate 2020/03/19
     */
    @RequestMapping(path = "/welink/user/save",method = RequestMethod.POST)
    public String save(@RequestBody WelinkBindRelationPO welinkBindRelationPO) throws Exception{
        return iWelinkUserService.save(welinkBindRelationPO);
    }

    /**
     * <desc>
     *      意见反馈
     * </desc>
     *
     * @param feedbackInfoPO
     * @return
     * @author Jiaqi.X
     * @createDate 2020/03/20
     */
    @RequestMapping(path = "/welink/user/saveFeedBack",method = RequestMethod.POST)
    public void saveFeedBack(@RequestBody FeedbackInfoPO feedbackInfoPO) throws Exception{
        iWelinkUserService.saveFeedBack(feedbackInfoPO);
    }

    /**
     * <desc>
     *      更新用户信息
     * </desc>
     *
     * @param appUserInfoPO
     * @return
     * @author Jiaqi.X
     * @createDate 2020/03/20
     */
    @RequestMapping(path = "/welink/user/updateUserInfo",method = RequestMethod.POST)
    public void updateUserInfo(@RequestBody AppUserInfoPO appUserInfoPO) throws Exception{
        iWelinkUserService.updateUserInfo(appUserInfoPO);
    }

    /**
     * <desc>
     *      获取用户信息
     * </desc>
     *
     * @param userId
     * @return
     * @author Jiaqi.X
     * @createDate 2020/01/23
     */
    @RequestMapping(path = "/welink/user/getUserInfo",method = RequestMethod.POST)
    public WelinkUserVO getUserInfo(@RequestParam ("userId") String userId){
        return iWelinkUserService.getUserInfo(userId);
    }
}